﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace Password_Generator
{
    class Generator
    {
        private bool _letters = Properties.Settings.Default.Letters;
        private bool _numbers = Properties.Settings.Default.Numbers;
        private bool _symbols = Properties.Settings.Default.Symbols;
        private bool _clip = false;
        private int _limit = Properties.Settings.Default.Limit;
        private char c;
        private string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZacbdefghijklmnopqrstuvwxyz";
        private string symbols = "`~!@#$%^&*()-_=+{}[]:;'?.>,<|;\"";
        private string numbers = "0123456789";
        private string _output = "";

        public void GeneratePassword()
        {


            Random rand = new Random();

            StringBuilder complex = new StringBuilder();
            StringBuilder password = new StringBuilder();

            int result = 0;

            for (int count = 0; count < Convert.ToInt32(Limit); count++)
            {
                if (Letters && Numbers && Symbols)
                {

                    complex.Append(letters);
                    complex.Append(numbers);
                    complex.Append(symbols);

                    result = rand.Next(complex.Length);

                    password.Append(c = complex[result]);



                }
                else if (Letters && Numbers && !Symbols)
                {
                    complex.Append(letters);
                    complex.Append(numbers);

                    result = rand.Next(complex.Length);

                    password.Append(c = complex[result]);

                }
                else if (Letters && Symbols && !Numbers)
                {
                    complex.Append(letters);
                    complex.Append(symbols);
                    result = rand.Next(complex.Length);

                    password.Append(c = complex[result]);

                }
                else if (!Letters && Symbols && Numbers)
                {
                    complex.Append(numbers);
                    complex.Append(symbols);
                    result = rand.Next(complex.Length);

                    password.Append(c = complex[result]);

                }
                else if (Letters && !Numbers && !Symbols)
                {
                    result = rand.Next(letters.Length);
                    password.Append(c = letters[result]);

                }
                else if (!Letters && Numbers && !Symbols)
                {

                    result = rand.Next(numbers.Length);
                    password.Append(c = numbers[result]);

                }
                else if (!Letters && !Numbers && Symbols)
                {

                    result = rand.Next(symbols.Length);
                    password.Append(c = symbols[result]);

                }


            }
            Output = password.ToString();

        }


        #region Properties


        public bool Letters
        {
            get { return _letters; }
            set
            {
                _letters = value;


            }
        }

        public bool Numbers
        {
            get { return _numbers; }
            set
            {
                _numbers = value;


            }
        }


        public bool Symbols
        {
            get { return _symbols; }
            set
            {
                _symbols = value;


            }
        }


        public bool Clip
        {
            get { return _clip; }
            set
            {
                _clip = value;

            }

        }


        public int Limit
        {
            get { return _limit; }
            set
            {
                _limit = value;


            }
        }

        public string Output
        {
            get
            {
                return _output;
            }
            set
            {
                _output = value;

            }
        }

        #endregion
    }
}
